﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace robot
{
    class Control
    {
        public int X { get; private set; }
        public int Y { get; private set; }

        public Control()
        {
            this.X = 5;
            this.Y = 5;
        }
        public void Step()
        {
            //Control c2 = new Control();

            Field f = new Field();
            f.DrawField();

            Render r = new Render();

            ConsoleKeyInfo key = new ConsoleKeyInfo();

            while (true)
            {
                key = Console.ReadKey();

                if (key.Key == ConsoleKey.DownArrow)
                {
                    this.Y++;
                    if (Y == 21)
                        Y--;
                    Console.SetCursorPosition(X, Y);
                    //r.DrawRobot(c2);
                    r.DrawRobot();
                    Console.SetCursorPosition(X, Y);
                }
                //else if (key.Key == ConsoleKey.W)
                //{
                //    Y--;
                //    if (Y == 0)
                //        Y++;
                //    Console.SetCursorPosition(X, Y);
                //    r.DrawRobot();
                //    Console.SetCursorPosition(X, Y);
                //}
                else if (key.Key == ConsoleKey.UpArrow)
                {
                    Y--;
                    if (Y == 0)
                        Y++;
                    Console.SetCursorPosition(X, Y);
                    r.DrawRobot();
                    Console.SetCursorPosition(X, Y);
                }
                else if (key.Key == ConsoleKey.LeftArrow)
                {
                    X--;
                    if (X == 0)
                        X++;
                    Console.SetCursorPosition(X, Y);
                    r.DrawRobot();
                    Console.SetCursorPosition(X, Y);
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    X++;
                    if (X == 38)
                        X--;
                    Console.SetCursorPosition(X, Y);
                    r.DrawRobot();
                    Console.SetCursorPosition(X, Y);
                }
            }
        }
    }
}
